<template>
  <div>
    <mheader></mheader>
    <div class="wrap">
      <el-form ref="ruleForm" :model="formMsg" :rules="rules" label-position="right" label-width="180px" size="medium">
        <!-- 确认补充材料对象 -->
        <el-row>
          <div class="detail_title">确认补充材料对象<span class="detail">请输入信息后点击匹配，确认递交材料的归属人</span></div>
        </el-row>
        <el-form-item label="主订单编号：" prop="code">
          <el-input v-model.trim="formMsg.code" maxlength="100" placeholder="请输入编号"/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="medium" @click.native="search()">查询匹配</el-button>
        </el-form-item>
        <!-- 提交员信息 -->
        <el-row>
          <el-col :span="24"><div class="detail_title">提交员信息</div></el-col>
        </el-row>
        <el-form-item label="姓名：" prop="supplierName">
          <el-input v-model="formMsg.supplierName" maxlength="20" placeholder="请输入姓名"/>
        </el-form-item>
        <el-form-item label="事业部：" prop="supplierDepartmentId">
          <el-select v-model="formMsg.supplierDepartmentId" placeholder="请选择">
            <el-option
              v-for="item in referee"
              :key="item.departmentId"
              :label="item.departmentName"
              :value="item.departmentId"/>
          </el-select>
        </el-form-item>
        <el-form-item label="邮箱：" prop="supplierEmail">
          <el-input v-model="formMsg.supplierEmail" maxlength="30" placeholder="请输入邮箱"/>&nbsp;@sunlands.com
        </el-form-item>
        <el-form-item label="手机号：" prop="supplierTel">
          <el-input v-model="formMsg.supplierTel" maxlength="11" placeholder="请输入手机号"/>
        </el-form-item>
        <!-- 补充材料信息 -->
        <el-row>
          <el-col :span="24"><div class="detail_title">补充材料信息</div></el-col>
        </el-row>
        <el-row>
          <el-col :span="24"><div class="msg">说明：</div></el-col>
          <el-col :span="24"><div class="msg">1. 一个文件类别如果被多次提交，系统只会保留最后一次上传的文件。</div></el-col>
          <el-col :span="24"><div class="msg">2. 未提交的文件不会更新。</div></el-col>
          <el-col :span="24"><div class="msg">3. 一个文件类别下无论有多少个文件，均会被新上传的数据整体覆盖。</div></el-col>
        </el-row>
        <el-row>
          <el-col :span="24"><div class="addMsg">必交材料信息查询</div></el-col>
        </el-row>
        <el-row>
          <el-col :span="3"><div>&nbsp;</div></el-col>
          <el-select v-model="formMsg.schoolID" placeholder="请选择">
            <el-option
              v-for="item in schoolList"
              :key="item.schoolId"
              :label="item.schoolName"
              :value="item.schoolId"/>
          </el-select>
          <el-button type="primary" size="medium" class="margin" @click.native="searchSchoolMsg()">查询</el-button>
        </el-row>
        <el-row>
          <el-col :span="24"><div class="necessaryData">{{necessaryData}}</div></el-col>
        </el-row>
        <el-form-item label="申请表：">
          <el-upload
          class="upload"
          accept='.docx,.pdf'
          :limit='1'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="applyTableSuccess"
          :on-remove="applyTableRemove"
          :file-list="formMsg.applyTable">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传word/pdf文件，最多1个文件且不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="学信网中文学历认证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='1'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="chsiCnEduSuccess"
          :on-remove="chsiCnEduRemove"
          :file-list="formMsg.chsiCnEdu">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多1个文件且不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="学信网英文学历认证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='1'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="chsiEnEduSuccess"
          :on-remove="chsiEnEduRemove"
          :file-list="formMsg.chsiEnEdu">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多1个文件且不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="护照扫描件：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="pasportSuccess"
          :on-remove="pasportRemove"
          :file-list="formMsg.pasport">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="身份证正反扫描件：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="idCardSuccess"
          :on-remove="idCardRemove"
          :file-list="formMsg.idCard">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="2寸证件照：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="identificationPicSuccess"
          :on-remove="identificationPicRemove"
          :file-list="formMsg.identificationPic">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="工作证明（盖公章）：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="workProveSuccess"
          :on-remove="workProveRemove"
          :file-list="formMsg.workProve">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="个人简历：">
          <el-upload
          class="upload"
          accept='.docx,.pdf'
          :limit='1'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="vitaeSuccess"
          :on-remove="vitaeRemove"
          :file-list="formMsg.vitae">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传word/pdf文件，最多1个文件且不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="学位网学位认证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='1'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="degreeIdentSuccess"
          :on-remove="degreeIdentRemove"
          :file-list="formMsg.degreeIdent">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多1个文件且不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="推荐信：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="recommendationSuccess"
          :on-remove="recommendationRemove"
          :file-list="formMsg.recommendation">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="90秒英文视频：">
          <el-upload
          class="upload"
          accept='.mp4,.avi,.mkv'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="enVideoSuccess"
          :on-remove="enVideoRemove"
          :file-list="formMsg.enVideo">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传mp4, avi, mkv格式，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="中文或英文个人陈述：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='1'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="statementSuccess"
          :on-remove="statementRemove"
          :file-list="formMsg.statement">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多1个文件且不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="第一阶段学位证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="fisrtStageDegreeSuccess"
          :on-remove="fisrtStageDegreeRemove"
          :file-list="formMsg.fisrtStageDegree">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="第二阶段学位证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="secondStageDegreeSuccess"
          :on-remove="secondStageDegreeRemove"
          :file-list="formMsg.secondStageDegree">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="第三阶段学位证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="thirdStageDegreeSuccess"
          :on-remove="thirdStageDegreeRemove"
          :file-list="formMsg.thirdStageDegree">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="第一阶段毕业证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="fisrtStageDiplomaSuccess"
          :on-remove="fisrtStageDiplomaRemove"
          :file-list="formMsg.fisrtStageDiploma">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="第二阶段毕业证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="secondStageDiplomaSuccess"
          :on-remove="secondStageDiplomaRemove"
          :file-list="formMsg.secondStageDiploma">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="第三阶段毕业证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="thirdStageDiplomaSuccess"
          :on-remove="thirdStageDiplomaRemove"
          :file-list="formMsg.thirdStageDiploma">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="第一阶段成绩单：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="fisrtStageReportSuccess"
          :on-remove="fisrtStageReportRemove"
          :file-list="formMsg.fisrtStageReport">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="第二阶段成绩单：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="secondStageReportSuccess"
          :on-remove="secondStageReportRemove"
          :file-list="formMsg.secondStageReport">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="第三阶段成绩单：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="thirdStageReportSuccess"
          :on-remove="thirdStageReportRemove"
          :file-list="formMsg.thirdStageReport">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多5个文件且每个文件不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="最高学历成绩单认证：">
          <el-upload
          class="upload"
          accept='.jpeg,.png,.jpg,.pdf'
          :limit='5'
          action="./recruit-api/v2/uploadImages"
          :headers = token
          :before-upload="beforeUpload"
          :on-success="scoreCardSuccess"
          :on-remove="scoreCardRemove"
          :file-list="formMsg.scoreCard">
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">只能上传jpg/png/jpeg/pdf文件，最多五张且单张不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" class="submit" size="medium" @click.native="onSubmit('ruleForm')">预览</el-button>
        </el-form-item>
        <el-row>
          <el-col :span="24"><div class="buttonTitle">*递交申请前，请您务必预览检查</div></el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
import COS from 'cos-js-sdk-v5'
import { getToken, dept } from '../api/stuEnrollInfo'
import { getStuHistoryAndApply, getOpenSchoolList } from '../api/additional'
import mheader from '@/components/mheader'
export default {
  name: 'additional',
  data () {
    var phone = (rules, value, callback) => {
      var reg = /^[1][0-9]{10}$/
      if (value === '') {
        callback(new Error('必填'))
      } else if (!reg.test(value)) {
        callback(new Error('手机号格式不正确'))
      } else {
        callback()
      }
    }
    var email = (rules, value, callback) => {
      var reg = /^[a-zA-Z][a-zA-Z0-9-]*$/
      if (value === '') {
        callback(new Error('必填'))
      } else if (!reg.test(value)) {
        callback(new Error('格式不正确'))
      } else {
        callback()
      }
    }
    return {
      formMsg: {
        isSearch: false,
        code: '',
        schoolID: '',
        supplierName: '',
        supplierDepartmentId: '',
        supplierEmail: '',
        supplierTel: '',
        applyTable: [], // 申请表
        chsiCnEdu: [], // 学信网中文学历认证
        chsiEnEdu: [], // 学信网英文学历认证
        pasport: [], // 护照
        idCard: [], // 身份证正反面扫描件
        identificationPic: [], // 2寸证件照
        workProve: [], // 工作证明
        vitae: [], // 个人简历
        degreeIdent: [], // 学位网认证图片
        recommendation: [], // 推荐信
        enVideo: [], // 英文视频
        statement: [], // 中文或英文个人陈述
        scoreCard: [], // 最高学历成绩单认证
        fisrtStageDegree: [], // 学位证
        secondStageDegree: [],
        thirdStageDegree: [],
        fisrtStageDiploma: [], // 毕业证
        secondStageDiploma: [],
        thirdStageDiploma: [],
        fisrtStageReport: [], // 成绩单
        secondStageReport: [],
        thirdStageReport: []
      },
      rules: {
        code: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        supplierName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        supplierDepartmentId: [
          { required: true, message: '必选', trigger: 'blur' }
        ],
        supplierEmail: [
          { validator: email, required: true, trigger: 'blur' }
        ],
        supplierTel: [
          { validator: phone, required: true, trigger: 'blur' }
        ]
      },
      token: {},
      stuEnrollId: [{
        value: 1,
        label: ' 主订单编号'
      }, {
        value: 2,
        label: '工单号'
      }],
      schoolList: [],
      necessaryData: '',
      referee: []// 事业部
    }
  },
  components: {
    mheader
  },
  computed: {
  },
  methods: {
    applyTableSuccess (response, file, fileList) {
      this.formMsg.applyTable = this.listFile(fileList, 'up')
    },
    applyTableRemove (file, fileList) {
      this.formMsg.applyTable = this.listFile(fileList, 'remove')
    },
    chsiCnEduSuccess (response, file, fileList) {
      this.formMsg.chsiCnEdu = this.listFile(fileList, 'up')
    },
    chsiCnEduRemove (file, fileList) {
      this.formMsg.chsiCnEdu = this.listFile(fileList, 'remove')
    },
    chsiEnEduSuccess (response, file, fileList) {
      this.formMsg.chsiEnEdu = this.listFile(fileList, 'up')
    },
    chsiEnEduRemove (file, fileList) {
      this.formMsg.chsiEnEdu = this.listFile(fileList, 'remove')
    },
    pasportSuccess (response, file, fileList) {
      this.formMsg.pasport = this.listFile(fileList, 'up')
    },
    pasportRemove (file, fileList) {
      this.formMsg.pasport = this.listFile(fileList, 'remove')
    },
    idCardSuccess (response, file, fileList) {
      this.formMsg.idCard = this.listFile(fileList, 'up')
    },
    idCardRemove (file, fileList) {
      this.formMsg.idCard = this.listFile(fileList, 'remove')
    },
    identificationPicSuccess (response, file, fileList) {
      this.formMsg.identificationPic = this.listFile(fileList, 'up')
    },
    identificationPicRemove (file, fileList) {
      this.formMsg.identificationPic = this.listFile(fileList, 'remove')
    },
    workProveSuccess (response, file, fileList) {
      this.formMsg.workProve = this.listFile(fileList, 'up')
    },
    workProveRemove (file, fileList) {
      this.formMsg.workProve = this.listFile(fileList, 'remove')
    },
    vitaeSuccess (response, file, fileList) {
      this.formMsg.vitae = this.listFile(fileList, 'up')
    },
    vitaeRemove (file, fileList) {
      this.formMsg.vitae = this.listFile(fileList, 'remove')
    },
    degreeIdentSuccess (response, file, fileList) {
      this.formMsg.degreeIdent = this.listFile(fileList, 'up')
    },
    degreeIdentRemove (file, fileList) {
      this.formMsg.degreeIdent = this.listFile(fileList, 'remove')
    },
    recommendationSuccess (response, file, fileList) {
      this.formMsg.recommendation = this.listFile(fileList, 'up')
    },
    recommendationRemove (file, fileList) {
      this.formMsg.recommendation = this.listFile(fileList, 'remove')
    },
    enVideoSuccess (response, file, fileList) {
      this.formMsg.enVideo = this.listFile(fileList, 'up')
    },
    enVideoRemove (file, fileList) {
      this.formMsg.enVideo = this.listFile(fileList, 'remove')
    },
    statementSuccess (response, file, fileList) {
      this.formMsg.statement = this.listFile(fileList, 'up')
    },
    statementRemove (file, fileList) {
      this.formMsg.statement = this.listFile(fileList, 'remove')
    },
    fisrtStageDegreeSuccess (response, file, fileList) {
      this.formMsg.fisrtStageDegree = this.listFile(fileList, 'up')
    },
    fisrtStageDegreeRemove (file, fileList) {
      this.formMsg.fisrtStageDegree = this.listFile(fileList, 'remove')
    },
    secondStageDegreeSuccess (response, file, fileList) {
      this.formMsg.secondStageDegree = this.listFile(fileList, 'up')
    },
    secondStageDegreeRemove (file, fileList) {
      this.formMsg.secondStageDegree = this.listFile(fileList, 'remove')
    },
    thirdStageDegreeSuccess (response, file, fileList) {
      this.formMsg.thirdStageDegree = this.listFile(fileList, 'up')
    },
    thirdStageDegreeRemove (file, fileList) {
      this.formMsg.thirdStageDegree = this.listFile(fileList, 'remove')
    },
    fisrtStageDiplomaSuccess (response, file, fileList) {
      this.formMsg.fisrtStageDiploma = this.listFile(fileList, 'up')
    },
    fisrtStageDiplomaRemove (file, fileList) {
      this.formMsg.fisrtStageDiploma = this.listFile(fileList, 'remove')
    },
    secondStageDiplomaSuccess (response, file, fileList) {
      this.formMsg.secondStageDiploma = this.listFile(fileList, 'up')
    },
    secondStageDiplomaRemove (file, fileList) {
      this.formMsg.secondStageDiploma = this.listFile(fileList, 'remove')
    },
    thirdStageDiplomaSuccess (response, file, fileList) {
      this.formMsg.thirdStageDiploma = this.listFile(fileList, 'up')
    },
    thirdStageDiplomaRemove (file, fileList) {
      this.formMsg.thirdStageDiploma = this.listFile(fileList, 'remove')
    },
    fisrtStageReportSuccess (response, file, fileList) {
      this.formMsg.fisrtStageReport = this.listFile(fileList, 'up')
    },
    fisrtStageReportRemove (file, fileList) {
      this.formMsg.fisrtStageReport = this.listFile(fileList, 'remove')
    },
    secondStageReportSuccess (response, file, fileList) {
      this.formMsg.secondStageReport = this.listFile(fileList, 'up')
    },
    secondStageReportRemove (file, fileList) {
      this.formMsg.secondStageReport = this.listFile(fileList, 'remove')
    },
    thirdStageReportSuccess (response, file, fileList) {
      this.formMsg.thirdStageReport = this.listFile(fileList, 'up')
    },
    thirdStageReportRemove (file, fileList) {
      this.formMsg.thirdStageReport = this.listFile(fileList, 'remove')
    },
    scoreCardSuccess (response, file, fileList) {
      this.formMsg.scoreCard = this.listFile(fileList, 'up')
    },
    scoreCardRemove (file, fileList) {
      this.formMsg.scoreCard = this.listFile(fileList, 'remove')
    },
    beforeUpload (file) {
      if (file.size > 5 * 1024 * 1024) {
        this.$message({ type: 'error', message: '请上传不超过5M的文件!' })
        return false
      }
    },
    // 过滤上传，删除图片返回值过滤错误信息
    listFile (list, type) {
      return list.reduce((arr, element) => {
        if (!(element.response.data && element.response.data.url) || element.response === 'token error !') {
          if (type === 'up') {
            this.$message.error('上传失败')
          } else {
            this.$message.error('删除失败')
          }
          return arr
        }
        arr.push(element)
        return arr
      }, [])
    },
    async search () {
      let { code } = this.formMsg
      if (code === '') {
        this.$alert('请填写主订单编号', '提示', { confirmButtonText: '确定' })
        return
      }
      let { data: { map } } = await getStuHistoryAndApply({ idType: 1, id: code })
      if (!map.stuName) {
        this.$alert('未查询到数据', '提示', { confirmButtonText: '确定' })
        return
      }
      this.$message({ type: 'success', message: '匹配成功!' })
      this.formMsg.isSearch = true
      Object.assign(this.formMsg, map)
    },
    searchSchoolMsg () {
      if (!this.formMsg.schoolID) return
      let { necessaryData } = this.schoolList.find(item => item.schoolId === this.formMsg.schoolID)
      this.necessaryData = necessaryData
    },
    onSubmit (ruleForm) {
      this.$refs[ruleForm].validate((valid) => {
        if (!valid) return
        if (!this.formMsg.isSearch) {
          this.$alert('未匹配到学员信息', '提示', { confirmButtonText: '确定' })
          return
        }
        sessionStorage.setItem('formMsg', JSON.stringify(this.formMsg))
        let { stuEnrollId, code, orderId, historyApplyList, stuName, supplierName, sex, supplierDepartmentId, supplierEmail, supplierTel, applyTable, chsiCnEdu, chsiEnEdu, pasport, idCard, identificationPic, workProve, vitae, degreeIdent, recommendation, enVideo, statement, fisrtStageDegree, secondStageDegree, thirdStageDegree, fisrtStageDiploma, secondStageDiploma, thirdStageDiploma, fisrtStageReport, secondStageReport, thirdStageReport, scoreCard } = this.formMsg
        let refereenObj = this.referee.find(item => item.departmentId === supplierDepartmentId)
        let allInfo = {
          stuEnrollId,
          code, // 主订单编号
          orderId,
          historyApplyList,
          stuName,
          sex,
          supplierName,
          supplierDepartmentName: refereenObj.departmentName,
          supplierDepartmentId,
          supplierEmail,
          supplierTel
        }
        // 补充条件
        let addList = [applyTable, chsiCnEdu, chsiEnEdu, pasport, idCard, identificationPic, workProve, vitae, degreeIdent, recommendation, enVideo, statement, fisrtStageDegree, secondStageDegree, thirdStageDegree, fisrtStageDiploma, secondStageDiploma, thirdStageDiploma, fisrtStageReport, secondStageReport, thirdStageReport, scoreCard]
        let addNames = ['applyTable', 'chsiCnEdu', 'chsiEnEdu', 'pasport', 'idCard', 'identificationPic', 'workProve', 'vitae', 'degreeIdent', 'recommendation', 'enVideo', 'statement', 'fisrtStageDegree', 'secondStageDegree', 'thirdStageDegree', 'fisrtStageDiploma', 'secondStageDiploma', 'thirdStageDiploma', 'fisrtStageReport', 'secondStageReport', 'thirdStageReport', 'scoreCard']
        addList.forEach((element, index) => {
          allInfo[addNames[index]] = element.reduce((arr, ele) => {
            arr.push(ele.response.data.url)
            return arr
          }, [])
        })
        sessionStorage.setItem('addPreview', JSON.stringify(allInfo))
        this.$router.push({ path: '/addPreview', query: {} })
      })
    }
  },
  async created () {
    let token = sessionStorage.getItem('token')
    if (!token) {
      const { data: { data } } = await getToken()
      token = data
      sessionStorage.setItem('token', token)
    }
    this.token = {
      'token': token,
      'type': 'h5'
    }
    let { data: { departmentList } } = await dept()
    let { data: { schoolList2 } } = await getOpenSchoolList()
    this.referee = departmentList
    this.schoolList = schoolList2
    if (JSON.parse(sessionStorage.getItem('formMsg')) === null) return
    this.formMsg = JSON.parse(sessionStorage.getItem('formMsg'))
  },
  mounted () {}
}
</script>
<style scoped lang="less">
  @main_color: #1C2F54;
  .wrap{
    padding: 0 160px;
    margin: 0 auto;
    .detail_title{
      font-size: 16px;
      height: 20px;
      border-bottom: 1px solid #DDE5F3;
      margin-bottom: 20px;
      .enroll{
        float: right;
        font-size: 13px;
        cursor: pointer;
      }
    }
    .addMsg{
      font-size: 16px;
      color: @main_color;
      line-height: 40px;
    }
    .msg{
      width: 750px;
      line-height: 30px;
      font-size: 12px;
      color: @main_color;
    }
    .margin{
      margin: 30px;
    }
    .detail{
      font-size: 14px;
      color: hsl(214, 14%, 52%);
    }
    .el-form{
      margin-top: 30px;
      font-size: 14px;
      .el-input, .el-select, .upload{
        width: 360px;
      }
      .submit{
        width: 300px;
      }
      .smallTitle{
        font-size: 14px;
        height: 20px;
        text-indent: 30px;
        color: @main_color;
        display: inline-block;
        margin-bottom: 20px;
      }
    }
    .openBtn{
      width: 660px;
      height: 50px;
      margin: 20px 0px;
      text-align: center;
      div{
        cursor: pointer;
        width: 100px;
        line-height: 40px;
        font-size: 16px;
        background: #A51C30;
        color: #fff;
        margin: 0 auto;
      }
    }
    .buttonTitle{
      width: 550px;
      text-align: center;
    }
  }
  .content{
      width: 895px;
      margin: 0 auto;
      padding: 30px 0px;
      color: @main_color;
      .detail_title{
        width: 750px;
        font-size: 16px;
        height: 30px;
        border-bottom: 1px solid #DDE5F3;
        margin-bottom: 20px;
      }
      /deep/.el-form-item__label{
        color: @main_color;
      }
      .detail{
        font-size: 14px;
        color: hsl(214, 14%, 52%);
      }
      .addMsg{
        font-size: 16px;
        color: @main_color;
        line-height: 40px;
      }
      .msg{
        width: 750px;
        line-height: 20px;
        font-size: 12px;
        color: @main_color;
      }
      .margin{
        margin-left: 300px;
      }
      .necessaryData{
        width: 400px;
        line-height: 20px;
        margin: 20px 0px;

      }
      .buttonTitle{
        width: 550px;
        text-align: center;
      }
      .el-form{
        width: 600px;
        font-size: 14px;
        .el-input{
          width: 260px;
        }
        .el-date-picker{
          width: 110px;
        }
        .submit{
          width: 300px;
        }
      }
  }
</style>
